package com.example.role_based_permission_control.service.impl;

import com.example.role_based_permission_control.dao.UserMapper;
import com.example.role_based_permission_control.entity.dto.User;
import com.example.role_based_permission_control.entity.dto.UserLoginDTO;
import com.example.role_based_permission_control.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 李云龙
 * @program: role_based_permmsion_control
 * @description:
 * @date 2024-09-01 15:46:06
 */
@Service
public class UserService implements IUserService {
    @Autowired(required = false)
    private UserMapper userMapper;

    @Override
    public User login(UserLoginDTO loginDTO) {
        User user = userMapper.selectUserByUsername(loginDTO.getUsername());
        if (user != null && user.getPassword().equals(loginDTO.getPassword())) {
            return user;
        }
        return null; // 登录失败，用户名或密码错误}
    }
}
